<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>2、三角形最小路径和</title>
</head>

<body>
  <script>
    function array(a) {
      for (let i = a.length - 2; i >= 0; i--) {
        for (let j = a[i].length; j >= 0; j--) {
          a[i][j] += Math.min(a[i + 1][j], a[i + 1][j + 1])
        }
      }
      return a[0][0]
    }
    document.write(array([[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]]))
  </script>
</body>

</html>